import Vue from 'vue'
import preloader from './preloader'

class Preloader {
  constructor () {
    this.PreloaderConstructor=Vue.extend(preloader);
  }
  open (options = {}) {
    if (typeof options === 'string') {
      options = {
        text: options
      }
    }
    this.instance = new this.PreloaderConstructor({
      data: options
    }).$mount();

    this.instance.show = true
    document.body.append(this.instance.$el)
  }
  close () {
    if(this.instance.show) this.instance.handleClose()
  }
}

export default Preloader